use sha1::{Digest, Sha1};
use std::path::Path;

// interface
pub trait Downloadable {
  fn download(&self, game_dir: &Path)
    -> Result<(), Box<dyn std::error::Error>>;
}
pub trait LibraryAllowed {
  fn allowed(&self) -> bool;
}

pub fn get<T: reqwest::IntoUrl>(
  url: T,
) -> reqwest::Result<reqwest::blocking::Response> {
  reqwest::blocking::Client::builder().timeout(None).build()?.get(url).send()
}

pub fn sha1<P: AsRef<Path>>(path: P) -> Result<String, std::io::Error> {
  let mut hasher = Sha1::new();
  file_hashing::get_hash_file(path, &mut hasher)
}

pub mod download_asset; // filename as modules
pub mod download_library;
pub mod download_version;
